﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using motelmanagement.common;
using System.Data;
using System.Data.OleDb;
namespace motelmanagement.dao
{
    class InformationMotelDAO
    {
        SqlUtil sqlUtil = new SqlUtil();
        OleDbCommand cmd = null;
        private string strSql = null;

        public DataTable getInforMotel()
        {
            cmd = new OleDbCommand("Select * from Information_motel");
            sqlUtil.Load(cmd);
            return sqlUtil;
        }
        public void insertInforMotel(string name1, string name2, string rating,
            string address, string phone, string fax, string email,
            string website, string police, string country, string about)
        {

            strSql = "Insert Into Information_motel(infor_name1,infor_name2,infor_rating";
            strSql += ",infor_address,infor_phone,infor_fax,infor_email,infor_website";
            strSql += ",infor_poice,infor_country,infor_about)";
            strSql += " Values(@name1,@name2,@rating,@add,@phone,@fax,@email";
            strSql += ",@website,@police,@country,@about)";
            cmd = new OleDbCommand(strSql);
            cmd.Parameters.Add("name1", SqlDbType.NText).Value = name1;
            cmd.Parameters.Add("name2", SqlDbType.NText).Value = name2;
            cmd.Parameters.Add("rating", SqlDbType.Text).Value = rating;
            cmd.Parameters.Add("add", SqlDbType.NText).Value = address;
            cmd.Parameters.Add("phone", SqlDbType.Text).Value = phone;
            cmd.Parameters.Add("fax", SqlDbType.Text).Value = fax;
            cmd.Parameters.Add("email", SqlDbType.Text).Value = email;
            cmd.Parameters.Add("website", SqlDbType.Text).Value = website;
            cmd.Parameters.Add("police", SqlDbType.NText).Value = police;
            cmd.Parameters.Add("country", SqlDbType.NText).Value = country;
            cmd.Parameters.Add("about", SqlDbType.NText).Value = about;
            sqlUtil.ExecuteNoneQuery(cmd);
        }
        public void updateInforMotel(int id,string name1, string name2, string rating,
           string address, string phone, string fax, string email,
           string website, string police, string country, string about)
        {

            strSql = "Update Information_motel Set infor_name1=@name1,infor_name2=@name2,infor_rating=@rating";
            strSql += ",infor_address=@add,infor_phone=@phone,infor_fax=@fax,infor_email=@email,infor_website=@website";
            strSql += ",infor_poice=@police,infor_country=@country,infor_about=@about";
            strSql += " Where infor_id=@id";
            cmd = new OleDbCommand(strSql);
            cmd.Parameters.Add("name1", SqlDbType.NText).Value = name1;
            cmd.Parameters.Add("name2", SqlDbType.NText).Value = name2;
            cmd.Parameters.Add("rating", SqlDbType.Text).Value = rating;
            cmd.Parameters.Add("add", SqlDbType.NText).Value = address;
            cmd.Parameters.Add("phone", SqlDbType.Text).Value = phone;
            cmd.Parameters.Add("fax", SqlDbType.Text).Value = fax;
            cmd.Parameters.Add("email", SqlDbType.Text).Value = email;
            cmd.Parameters.Add("website", SqlDbType.Text).Value = website;
            cmd.Parameters.Add("police", SqlDbType.NText).Value = police;
            cmd.Parameters.Add("country", SqlDbType.NText).Value = country;
            cmd.Parameters.Add("about", SqlDbType.NText).Value = about;
            cmd.Parameters.Add("id", SqlDbType.Int).Value = id;
            sqlUtil.ExecuteNoneQuery(cmd);
        }
        public void deleteInforMotel(int id) {
            cmd = new OleDbCommand("Delete From Information_motel Where infor_id=@id");
            cmd.Parameters.Add("id", SqlDbType.Int).Value = id;
            sqlUtil.ExecuteNoneQuery(cmd);
        }
    }
}
